package com.tmpt.dao.intf;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.tmpt.dto.Result;
import org.hibernate.HibernateException;

import com.tmpt.beans.A1TemplateTable;

public interface ITemplateDao{

	public List<Map<String, Object>> queryReportBySearch(String reportSqlString);

	/**
	 * 查询列表
	 * @param sqlstring
	 * @param paramList
	 * @return
	 */
	public List<Map<String, Object>> queryListBySearch(String sqlstring, List<Object> paramList);
	public int queryCountBySearch(String sqlstring, List<Object> paramList);
	
	//public List<Map<String, Object>> getRightMenuList(long tableId);
	public long addData(String tableName, List<Map<String, Object>> column_list) throws HibernateException, SQLException;
	public long editData(String tableName, String id, List<Map<String, Object>> column_list) throws HibernateException, SQLException;

	public Result templateSearch(A1TemplateTable table, Map<String, String[]> paramMap,String[] params) throws Exception;
	//根据用户自定义的SQL Join查询
	public Result templateSearchByTableNameSql(A1TemplateTable table, Map<String, String[]> paramMap,String[] params) throws Exception;
	//根据用户自定义的SQL查询
	public Result templateSearchBySql(A1TemplateTable table, Map<String, String[]> paramMap) throws Exception;
	
	//根据用户自定义的SQL查询
	public Result templateSearchByProcedure(A1TemplateTable table, Map<String, String[]> paramMap) throws Exception;
		
	/**
	 * 取表有哪些列
	 * @param table
	 * @return
	 */
	public List<Map<String, Object>> loadColumn(A1TemplateTable table);

	/**
	 * 取表主键
	 * @param table
	 * @return
	 */
	public String loadTablePrimaryKey(A1TemplateTable table);
	
	/**
	 * 执行存储过程
	 * @param procedure
	 * @param paramMap
	 * @return
	 */
	public Result executeProcedureJob(String procedure, Map<String, Object> paramMap);
	

	/**
	 * 直接通过表名和列名查询数据
	 * @param tableName
	 * @param columnName
	 * @return
	 */
	public List<String> queryDB(String tableName, String columnName);
	
	
	/**
	 * 查询两列
	 * @param tableName
	 * @param columnNameLabel
	 * @param columnNameValue
	 * @return
	 */
	public List<Map<String,Object>> queryDB(String tableName, String columnNameLabel, String columnNameValue);
	
	

	
	public List<Map<String,Object>> queryDB(String targetTableName, String targetColumns, String targetPrimaryKey, int targetTableId);

	public List<Map<String,Object>> queryDBLast(String targetTableName, String targetColumns, String targetPrimaryKey);
	
	/**
	 * 不存在表名就创建一张表
	 * @param tableName
	 * @return
	 * @throws HibernateException
	 * @throws SQLException
	 */
	public boolean createTableNotExist(String tableName) throws HibernateException, SQLException;
	
	

	/**
	 * 不存在的列就alter table add column
	 * @param tableName
	 * @param columnName
	 * @return
	 * @throws HibernateException
	 * @throws SQLException
	 */
	public boolean alterColumnNotExist(String tableName, String columnName, String column_dataType, String column_isNull) throws HibernateException, SQLException;


	/**
	 * 生成SQL语句给Mybatis使用
	 * @param table
	 * @return
	 * @throws Exception
	 */
	public Result queryColumnAliasAndProperty(A1TemplateTable table) throws Exception;

}
